#include<bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> freq;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        freq[x]++;
    }
    vector<pair<int, int>> v;
    for (auto p: freq) {
        v.push_back(p);
    }
    sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b) {
        if (a.second == b.second) {
            return a.first < b.first;
        }
        return a.second > b.second;
    });
    int k = v[0].second;
    for (auto p: v) {
        if (k == p.second)
            cout << p.first << " " << p.second << endl;
    }
    return 0;
}